Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix code scanning alert no. 21: URL redirection from remote source #518

Merged
merged 2 commits into from
Oct 19, 2024

Conversation

TreyWW
Copy link
Owner

@TreyWW TreyWW commented Oct 19, 2024

Fixes https://github.com/TreyWW/MyFinances/security/code-scanning/21

To fix the problem, we need to validate the redirect_url to ensure it is a safe and allowed URL. We can use Django's url_has_allowed_host_and_scheme function to check that the URL is safe to redirect to. This function ensures that the URL does not contain an explicit host name and is within the allowed hosts.

  1. Import the url_has_allowed_host_and_scheme function from django.utils.http.
  2. Modify the redirect_to_login function to validate the redirect_url using url_has_allowed_host_and_scheme.
  3. If the redirect_url is not valid, redirect to a default safe URL (e.g., the home page).

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Copy link
Contributor

github-actions bot commented Oct 19, 2024

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files

@TreyWW TreyWW marked this pull request as ready for review October 19, 2024 20:09
@TreyWW TreyWW merged commit 118e3cf into main Oct 19, 2024
9 checks passed
@TreyWW TreyWW deleted the alert-autofix-21 branch October 19, 2024 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant